// --------------------------------------------------------------------------
//
//	Bolt Action Marksman's Rifle "Silver Hand"
//
// --------------------------------------------------------------------------

Actor BoltRifle : BrutalWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 10
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Clip3"
	Weapon.AmmoType2 "BoltRifleAmmo"
	Weapon.SelectionOrder 9500
	Weapon.Kickback 200
	-WEAPON.CHEATNOTWEAPON
	+WEAPON.NOAUTOAIM
    +WEAPON.NOALERT
	+WEAPON.NOAUTOFIRE
    Inventory.PickupSound "M40RIF3"
	Inventory.PickupMessage "You got the ''Silver Hand'' Marksman's Rifle! (Slot 8)"
	Obituary "%o was layed down by %k's Silver Hand."
	tag "Sniper rifle"
    Scale 0.8
	Inventory.ForbiddenTo Sorcerer, Paladin, Corvus
	States
	{
	Spawn:
		SILV A -1
		Stop
	Select:
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		//TNT1 A 0 A_Takeinventory("IdleCounter",200)
		TNT1 A 5
		TNT1 A 0 A_Raise
	    Goto ReadyPlaceholder
		ReadyPlaceholder:
		SHSS A 0 
		TNT1 A 0 A_PlaySound("revolver/draw")
		//BLRS ABCDEF 1 A_WeaponReady(WRF_NOFIRE)
		BLRS ABCD 1 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
	Deselect:
        TNT1 A 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
		TNT1 A 0 A_GunFlash("MudOff")
		TNT1 A 0 A_SetCrosshair(0)
		TNT1 A 0 A_PlaySound("weapons/changing")
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_JumpIfInventory("Zoomed", 1, 2)
		TNT1 A 0 A_Jump(256, 7)
		BLRF A 1
		TNT1 A 0 A_TakeInventory("Zoomed", 1)
		BLRF A 1
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("TossGrenade",1)
		TNT1 A 1 A_Takeinventory("Unloading",1)
		TNT1 A 0 A_Lower
		Wait		
	Ready:
	Ready3:
        TNT1 A 0 A_JumpIfInventory("GoFatality", 1, "GoingToReady")
	Ready1:
        BLRF A 1
	Ready2:
		// This is placed here for now, should be moved if there is a replaying
		// idle animation for weapons
	ReadyLoop:
		TNT1 A 0 A_SetCrosshair(0)
        TNT1 A 0 A_JumpIfInventory("Zoomed", 1, "ReadyZoom")
        TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        //TNT1 A 0 A_JumpIfInventory("Taunting",1,"TauntR")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"Salute")
        TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		//TNT1 A 0 A_JumpIfInventory("IdleCounter",200,"PlayerIsIdle")
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		BLRF A 1 A_WeaponReady
		Loop
	AltFire:
        TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"ZoomOut")
		TNT1 A 0 A_Giveinventory("Zoomed",1)
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_SetCrosshair(41)
        TNT1 A 0 A_ZoomFactor(1.5)
		TNT1 A 0 A_Giveinventory("ADSmode",1)
        BLRZ ABCD 1
        Goto ReadyZoom
	ZoomOut:
        TNT1 AAAAAA 0
        BLRZ DCBA 1
		TNT1 A 0 A_Takeinventory("Zoomed",1)
        TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_SetCrosshair(0)
        Goto Ready2
    ReadyZoom:
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"WeapSpecial")
		BLRZ E 1 A_WeaponReady
		Loop
	ZoomOutFire:
		TNT1 A 0 A_PlaySound("M40Rifle/Scope")
		TNT1 A 0 A_TakeInventory("Zoomed", 1)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		BLRF A 1 A_ZoomFactor(1.0,ZOOM_INSTANT)
		TNT1 A 0 A_GunFlash("MudOff")
		TNT1 A 0 A_SetCrosshair(0)
		BLRF A 1
		TNT1 A 0 A_JumpIfInventory("SniperAttackState",10,46)
		TNT1 A 0 A_JumpIfInventory("SniperAttackState",9,41)
		TNT1 A 0 A_JumpIfInventory("SniperAttackState",8,37)
		TNT1 A 0 A_JumpIfInventory("SniperAttackState",7,34)
		TNT1 A 0 A_JumpIfInventory("SniperAttackState",6,30)
		TNT1 A 0 A_JumpIfInventory("SniperAttackState",5,27)
		TNT1 A 0 A_JumpIfInventory("SniperAttackState",4,21)
		TNT1 A 0 A_JumpIfInventory("SniperAttackState",3,17)
		TNT1 A 0 A_JumpIfInventory("SniperAttackState",2,13)
		TNT1 A 0 A_JumpIfInventory("SniperAttackState",1,10)
		Goto Ready2
	Fire:
		TNT1 A 0 A_JumpIfInventory("Zoomed", 1, "FireZoom")
        TNT1 A 0 A_JumpIfInventory("BoltRifleAmmo",1,1)
        Goto Reload
		TNT1 A 0
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_TAKEINVENTORY ("BoltRifleAmmo",1)
		TNT1 A 0 A_FireBullets (0.5, 0.5, -1, random(120,210), "ShotgunPuff", FBF_NORANDOM)
        TNT1 A 0 A_FireCustomMissile("DecorativeTracer", frandom(-0.5,0.5), 0, 0, -12, 0, frandom(-0.5,0.5))
		TNT1 A 0 A_PlaySound("M40Rifle/Fire")
		TNT1 A 0 A_FireCustomMissile("ShakeYourAss", 0, 0, 0, 0)
		TNT1 A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
		TNT1 A 0 A_SetPitch(Pitch-1)
		BLRF A 0
		BLRF F 2 BRIGHT
		BLRF BBCCDD 1
		TNT1 A 0 A_JumpIfInventory("BoltRifleAmmo",1,1)
		Goto SkipBolting
		BLRR BC 1
		BLRR DEF 2
		TNT1 A 0 A_PlaySound("M40Rifle/Bolt1", 3)
		BLRR GHI 2
		TNT1 A 0 A_FireCustomMissile("HeavyRifleCaseSpawn",5,0,6,-10)
		TNT1 A 0 A_PlaySound("M40Rifle/Bolt2", 3)
		BLRR JKLMNO 2
		SkipBolting:
		TNT1 A 0 A_Takeinventory("SniperAttackState",10)
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("TossGrenade",1)
		Goto Ready2
	FireZoom:
        TNT1 A 0 A_JumpIfInventory("BoltRifleAmmo",1,1)
        Goto Reload
        TNT1 A 0 A_Takeinventory("BoltRifleAmmo",1)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound("M40Rifle/Fire")
		BLRZ F 1 BRIGHT A_FireBullets (0, 0, -1, random(120,210), "ShotgunPuff", FBF_NORANDOM)
        TNT1 A 0 A_FireCustomMissile("ShakeYourAss", 0, 0, 0, 0)
		TNT1 A 0 A_SpawnItemEx("PlayerMuzzle1",30,0,45)
		TNT1 A 0 A_FireCustomMissile("DecorativeTracer", 0, 0, 0, -12, 0, 0)
		BLRZ GH 2		
		TNT1 A 0 A_SetPitch(Pitch-1)
		
		TNT1 A 0 A_ZoomFactor(1.0)
		BLRZ DCBA 1
		 
		TNT1 A 0 A_JumpIfInventory("BoltRifleAmmo",1,1)
		Goto SkipBoltingZoom
		BLRR BC 1
		BLRR DEF 2
		TNT1 A 0 A_PlaySound("M40Rifle/Bolt1", 5)
		BLRR GHI 2
		TNT1 A 0 A_FireCustomMissile("HeavyRifleCaseSpawn",5,0,6,-10)
		TNT1 A 0 A_PlaySound("M40Rifle/Bolt2", 5)
		BLRR JKLMNO 2
		SkipBoltingZoom:
		TNT1 A 0 A_Takeinventory("SniperAttackState",10)
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("TossGrenade",1)
		
		TNT1 A 0 A_ZoomFactor(1.5)
		BLRZ ABCD 1
				
		Goto ReadyZoom


	WeapSpecial:
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_JumpIfInventory("SniperZoomFactor", 1, 5)
		//TNT1 A 0 A_GunFlash("ChangeZoom")
		TNT1 A 0 A_GiveInventory("SniperZoomFactor", 1)
		TNT1 A 0 A_PlaySound("M40Rifle/Scope")
		TNT1 A 0 A_ZoomFactor(8.0,ZOOM_INSTANT)
		SNPZ Z 2
		Goto ReadyZoom
		TNT1 A 0 A_JumpIfInventory("SniperZoomFactor", 2, 5)
		//TNT1 A 0 A_GunFlash("ChangeZoom")
		TNT1 A 0 A_GiveInventory("SniperZoomFactor", 1)
		TNT1 A 0 A_PlaySound("M40Rifle/Scope")
		TNT1 A 0 A_ZoomFactor(16.0,ZOOM_INSTANT)
		SNPZ Z 2
		Goto ReadyZoom
		//TNT1 A 0 A_GunFlash("ChangeZoom")
		TNT1 A 0 A_TakeInventory("SniperZoomFactor", 2)
		TNT1 A 0 A_PlaySound("M40Rifle/Scope")
		TNT1 A 0 A_ZoomFactor(4.0,ZOOM_INSTANT)
		SNPZ Z 2
		Goto ReadyZoom

	ChangeZoom:
		SNPZ W 2
	MudOn:
		SNPZ X 1
		loop
	MudOff:
		TNT1 A 1
		Stop

	DryFire:
		TNT1 A 0 A_PlaySound("weapons/empty")
		Goto Ready2
		
    Reload:
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_JumpIfInventory("BoltRifleAmmo",11,"Ready2")
		TNT1 A 0 A_JumpIfInventory("Clip3",1,1)
		Goto DryFire
		TNT1 A 0 A_SetCrosshair(41)
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,"Refill")
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,2)
	Goto ReloadAnimStart
		TNT1 A 0 A_TakeInventory("Zoomed", 1)
		TNT1 A 0 A_PlaySound("M40Rifle/Scope")
		TNT1 A 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
		TNT1 A 0 A_GunFlash("MudOff")
		TNT1 A 0 A_SetCrosshair(0)
	    TNT1 A 0
	ReloadAnimStart:
		BRR1 ABCDEFG 2
		TNT1 A 0 A_PlaySound("Reload")
		TNT1 A 0 A_JumpIfInventory("BoltRifleAmmo",1,2)
		TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
		TNT1 A 0
        BRR2 ABCDEFGHIJKLMNOPRST 2
		TNT1 A 0 A_JumpIfInventory("BoltRifleAmmo",1,"SkipBoltingOnReload")
		BLRR DEF 2
		TNT1 A 0 A_PlaySound("M40Rifle/Bolt1", 5)
		BLRR GHI 2
		TNT1 A 0 A_FireCustomMissile("HeavyRifleCaseSpawn",5,0,6,-10)
		TNT1 A 0 A_PlaySound("M40Rifle/Bolt2", 5)
		BLRR JKLMNO 2
		SkipBoltingOnReload:
		TNT1 A 0 A_Takeinventory("SniperAttackState",10)
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("TossGrenade",1)

	Refill:
		TNT1 A 0 A_JumpIfInventory("BoltRifleAmmo", 1, "ReloadLoop11") //10+1 if not empty
		
	ReloadLoop10:
		TNT1 A 0 A_JumpIfInventory("BoltRifleAmmo",10,"ReloadDone")
		TNT1 A 0 A_JumpIfInventory("Clip3",1,1)
		Goto ReloadDone
		TNT1 A 0 A_Giveinventory("BoltRifleAmmo",1)
		TNT1 A 0 A_Takeinventory("Clip3",1)
		Goto ReloadLoop10
		
	ReloadLoop11:
		TNT1 A 0 A_JumpIfInventory("BoltRifleAmmo",11,"ReloadDone")
		TNT1 A 0 A_JumpIfInventory("Clip3",1,1)
		Goto ReloadDone
		TNT1 A 0 A_Giveinventory("BoltRifleAmmo",1)
		TNT1 A 0 A_Takeinventory("Clip3",1)
		Goto ReloadLoop11

	ReloadDone:
		TNT1 A 0 A_Refire
		Goto Ready2

	KickFlash:
		SNPK ABCD 1
		SNPK E 8
		SNPK DCBA 1
		SNPF A 1
		Stop
		
	AirKickFlash:
		SNPK ABCD 1
		SNPK E 10
		SNPK DCBA 1
		SNPF A 1
		Stop
		
	TauntFlash:
		SNPK ABCD 1
		SNPK E 35
		SNPK DCBA 1
		SNPF A 1
		Stop
		
	GrenadeFlash:
		SNPS ABCDE 1
		Stop
	}
}

ACTOR SniperAttackState : Inventory { Inventory.MaxAmount 10 }

ACTOR SniperZoomFactor : Inventory { Inventory.MaxAmount 2 }

ACTOR WeapSpecial : Inventory { Inventory.MaxAmount 1 }

ACTOR BoltRifleAmmo : Ammo
{
	+INVENTORY.IGNORESKILL
	Inventory.Amount 0
	Inventory.MaxAmount 11
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 11
   	Inventory.Icon "SILVA0"
}